var script = {
    url : null,
    init : function (url) {
        script.url = url
        $('#btn_script').text('开始脚本')
        $('#btn_script').click(function () {
            if ($('#btn_script').text() == '开始脚本') {
                script.start()
            } else if ($('#btn_script').text() == '结束脚本') {
                script.end()
            }
        })
    },
    start : function () {
        app.init(script.url)
        function random(start, end) {
            var num = null
            var result = function() {
                num = Math.round(Math.random() * end)
            }
            do {
                result()
            } while (num < start)
            return num
        }
        $.post(script.url + '/script/start', function (res) {
            if(res.msg == 'success'){
                $('#btn_script').text('结束脚本')
            }
        })
    },
    end : function () {
        $.post(script.url + '/script/end', function (res) {
            if(res.msg == 'success'){
                $('#btn_script').text('开始脚本')
            }
        })
    }
}